sgdk
|
SGDK Tile cache engine (tile VRAM management) More...
#include "vdp_tile.h"
Go to the source code of this file.
Classes | |
struct | TCBloc |
Tile cache bloc structure. More... | |
struct | TileCache |
Tile cache information structure. More... | |
Enumerations | |
enum | TCUpload { NO_UPLOAD, UPLOAD_VINT, UPLOAD_NOW } |
Tile cache upload action. | |
Functions | |
void | TC_init () |
Initialize the TileSet cache engine. | |
void | TC_end () |
End the TileSet cache engine. | |
void | TC_createCache (TileCache *cache, u16 startIndex, u16 size) |
Initialize a new TileSet cache structure. | |
void | TC_createCacheEx (TileCache *cache, u16 startIndex, u16 size, u16 numBloc) |
Initialize a new TileSet cache structure. | |
void | TC_releaseCache (TileCache *cache) |
Release the TileSet cache structure. | |
void | TC_clearCache (TileCache *cache) |
Clear the specified TileSet cache. | |
void | TC_flushCache (TileCache *cache) |
Flush the specified TileSet cache. | |
s16 | TC_alloc (TileCache *cache, TileSet *tileset, TCUpload upload) |
Allocate the specified TileSet in VRAM with given Tile cache and return its index. If TileSet is already present in VRAM, no special operation is done else the TileSet will be automatically uploaded at the next VInt. If the specified TileSet is compressed the method unpack it and store it in a temporary TileSet until it is send to VRAM. | |
s16 | TC_reAlloc (TileCache *cache, TileSet *tileset) |
Re-allocate a TileSet which is still present in cache after a flush operation. If the TileSet is not anymore in the tile cache the method return -1. | |
void | TC_free (TileCache *cache, TileSet *tileset) |
Release VRAM allocation of the specified TileSet. The tileSet remains in VRAM but will be the bloc will be marked as flushed so it can be overwritten by another bloc at any time. | |
s16 | TC_getTileIndex (TileCache *cache, TileSet *tileset) |
Return the VRAM tile index of specified TileSet in the given Tile cache. If the TileSet is not found then -1 is returned. | |
void | TC_uploadAtVBlank (TileSet *tileset, u16 index) |
Will upload the specified Tileset at given VRAM tile position during VBlank. |
SGDK Tile cache engine (tile VRAM management)
Tile (in TileSet form) cache engine.
It offerts methods to manage VRAM usage for tile data.
Allocate the specified TileSet in VRAM with given Tile cache and return its index.
If TileSet is already present in VRAM, no special operation is done else the TileSet will be automatically uploaded at the next VInt.
If the specified TileSet is compressed the method unpack it and store it in a temporary TileSet until it is send to VRAM.
cache | Cache used for allocation. |
tileset | The TileSet to put in VRAM. |
upload | Upload action, possible values are: NO_UPLOAD don't upload tileset to VRAM (only return index) UPLOAD_VINT upload to VRAM will be done automatically at VInt time (VBlank area) UPLOAD_NOW upload to VRAM now |
void TC_clearCache | ( | TileCache * | cache | ) |
Clear the specified TileSet cache.
cache | Cache we want to clear. |
void TC_createCache | ( | TileCache * | cache, |
u16 | startIndex, | ||
u16 | size | ||
) |
Initialize a new TileSet cache structure.
cache | Cache to initialize. |
startIndex | Tile start index in VRAM for the cache. |
size | Size in tile of the cache. |
Set parameters and allocate some memory for the cache (~1KB).
void TC_createCacheEx | ( | TileCache * | cache, |
u16 | startIndex, | ||
u16 | size, | ||
u16 | numBloc | ||
) |
Initialize a new TileSet cache structure.
cache | Cache to initialize. |
startIndex | Tile start index in VRAM for the cache. |
size | Size in tile of the cache. |
numBloc | Number of bloc of the cache. |
Set parameters and allocate some memory for the cache (~1KB).
void TC_end | ( | ) |
End the TileSet cache engine.
Release some memory and disable attached VInt processing.
void TC_flushCache | ( | TileCache * | cache | ) |
Flush the specified TileSet cache.
cache | Cache we want to flush. |
This is not exactly the same as the clear operation:
Allocated tileset remains in cache but they can be erased with newly allocated tileset.
void TC_init | ( | ) |
Initialize the TileSet cache engine.
Allocate some memory and enable VInt process.
Re-allocate a TileSet which is still present in cache after a flush operation.
If the TileSet is not anymore in the tile cache the method return -1.
cache | Cache where we want to reallocate the TileSet. |
tileset | The TileSet to re allocate if possible. |
void TC_releaseCache | ( | TileCache * | cache | ) |